package cloud.maque.module.system.controller;

import cloud.maque.common.core.request.PageRequest;
import cloud.maque.common.core.response.R;
import cloud.maque.module.system.entity.SysConfig;
import cloud.maque.module.system.service.ConfigService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 参数接口
 */
@Tag(name = "参数接口")
@RestController
@RequestMapping(value = "/config")
public class ConfigController {


    @Autowired
    ConfigService configService;

    @Operation(summary = "参数列表")
    @PostMapping("/list")
    public R<IPage<SysConfig>> List(@RequestBody PageRequest<SysConfig> pageReq) {
        return R.ok("OK", configService.GetList(pageReq));
    }

    @Operation(summary = "参数保存")
    @PostMapping("/save")
    public R<SysConfig> Save(@RequestBody SysConfig data) {

        return R.ok("OK", configService.SaveConfig(data));
    }

    @Operation(summary = "参数状态修改")
    @PostMapping("/edit-status")
    public R<SysConfig> EditStatus(@RequestBody SysConfig data) {
        return R.ok("OK", configService.EditStatus(data));
    }


    @Operation(summary = "参数删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> Delete(@PathVariable("id") String id) {
        return R.ok("OK", configService.DeleteConfig(id));
    }
}
